<?php
/**
 * 轻云网络验证系统
 * =======================================================
 * 版权所有(C) 2019-2039 daenx.cn，并保留所有权利。
 * 作者：Daen大恩
 * 作者QQ: 1330166565
 * 开发群：661059773
 * =======================================================
 */
    include 'farmwork.php';
	header("content-type:text/html;charset=utf-8");
	login();
	
	$id = $_GET['id'];
	$sql = "SELECT * FROM `products` WHERE id ='$id';";
	$result=mysqli_query($con,$sql);
	if($result&&mysqli_num_rows($result)){
	   while ($row=mysqli_fetch_assoc($result)) {
			  $cp = $row['cp'];
			  $ms = $row['ms'];
			  $nver = $row['nver'];
			  $nkey = $row['nkey'];
			  $zt = $row['zt'];
			  $url = $row['url'];
			  $qz = $row['qz'];
			  $qt = $row['qt'];
			  $free = $row['free'];
				$jg1 = $row['jg1'];
				$jg2 = $row['jg2'];
				$jg3 = $row['jg3'];
				$jg4 = $row['jg4'];
				$jg5 = $row['jg5'];
				$jg6 = $row['jg6'];
					$xjjg1 = $row['xjjg1'];
					$xjjg2 = $row['xjjg2'];
					$xjjg3 = $row['xjjg3'];
					$xjjg4 = $row['xjjg4'];
					$xjjg5 = $row['xjjg5'];
					$xjjg6 = $row['xjjg6'];
		$kf = $row['kf'];
		$qd = $row['qd'];
		$qd_rmb = $row['qd_rmb'];
		$alive = $row['alive'];
	   }
	}
	
	$action = $_GET['action'];
	if($action=='do'){
		$id = $_POST['id'];
		$cp = $_POST['cp'];
		$ms = $_POST['ms'];
		$zt = $_POST['zt'];
		$nver = $_POST['nver'];
		$nkey = $_POST['nkey'];
		$url = $_POST['url'];
		$qz = $_POST['qz'];
		$qt = $_POST['qt'];
		$free = $_POST['free'];
		$jg1 = $_POST['jg1'];
		$jg2 = $_POST['jg2'];
		$jg3 = $_POST['jg3'];
		$jg4 = $_POST['jg4'];
		$jg5 = $_POST['jg5'];
		$jg6 = $_POST['jg6'];
				$xjjg1 = $_POST['xjjg1'];
				$xjjg2 = $_POST['xjjg2'];
				$xjjg3 = $_POST['xjjg3'];
				$xjjg4 = $_POST['xjjg4'];
				$xjjg5 = $_POST['xjjg5'];
				$xjjg6 = $_POST['xjjg6'];
		$kf = $_POST['kf'];
		$qd = $_POST['qd'];
		$qd_rmb = $_POST['qd_rmb'];
		$alive = $_POST['alive'];
		$sql = "UPDATE `products` SET `cp` = '$cp', `ms` = '$ms', `nver` = '$nver', `nkey` = '$nkey', `url` = '$url', `qz` = '$qz',`qt` = '$qt', `free` = '$free', `zt` = '$zt', `jg1` = '$jg1', `jg2` = '$jg2', `jg3` = '$jg3', `jg4` = '$jg4', `jg5` = '$jg5', `jg6` = '$jg6',`xjjg1` = '$xjjg1', `xjjg2` = '$xjjg2', `xjjg3` = '$xjjg3', `xjjg4` = '$xjjg4', `xjjg5` = '$xjjg5', `xjjg6` = '$xjjg6', `kf` = '$kf', `qd` = '$qd', `qd_rmb` = '$qd_rmb', `alive` = '$alive' WHERE `id` = '$id';";
		mysqli_query($con,$sql);
		$sql = "UPDATE `version` SET  `dkey` = '$nkey', `url` = '$url', `qz` = '$qz' WHERE `ver` = '$nver' and `cp` = '$cp';";
	    mysqli_query($con,$sql);
		mysqli_close();
		echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">更新成功！</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'products.php' });  }});</script>");
	}

$li9='class="active"';
$li90='class="active"';
?>
<?php include 'header.php';?>
    <title>更新产品-<?php echo $title?></title>
<?php include 'list.php';?>
    <!--main content start-->
    <section id="main-content">
        <section class="wrapper">
<?php include 'overview.php';?>
            <div class="row">
                <div class="col-lg-12">
                    <!--work progress start-->
                    <section class="panel">
                        <div class="panel-body progress-panel">
                            <div class="task-progress">
                                <h1>更新新产品</h1>
                                <p>填写新的产品信息并保存.修改会同步修改最新版本的相应信息</p>
                            </div>
                        </div>
                         <form action="products-chanage.php?action=do" method="post" role="form">
                            <div class="form-group">
                                <label for="txtDomain">产品</label>
                                <input type="text" name="cp" class="form-control" value='<?php echo $cp?>'>
                            </div>
                            <div class="form-group">
                                <label for="txtDomain">公告   (请勿使用回车换行，推荐使用< br >)</label>
                                
								<textarea class="form-control" name="ms" clos="100" rows="5"/><?php echo $ms?></textarea>
                            </div>
							<div class="form-group">
                                <label for="txtDomain">最新版本(版本号不允许修改，如果有需要，请重新发布新版本)</label>
                                <input type="text" name="nver" class="form-control" value='<?php echo $nver?>'>
                            </div>
							<div class="form-group">
                                <label for="txtDomain">存活时间(单位秒)</label>
                                <input type="text" name="alive" class="form-control" value='<?php echo $alive?>'>
                            </div>
							<div class="form-group">
							  <label>是否强制更新</label>
							  <select name="qz" class="form-control">
							  <?php if($qz == 1)
											{echo '<option value="0">否</option>
                                            <option value="1" selected>是</option>';}
											else 
											{echo '<option value="0" selected>否</option>
                                            <option value="1">是</option>';}
											?>
							  

							  </select>
							</div>
							<div class="form-group">
							  <label>是否免费</label>
							  <select name="free" class="form-control">
							  <?php if($free == 1)
											{echo '<option value="0">否</option>
                                            <option value="1" selected>是</option>';}
											else 
											{echo '<option value="0" selected>否</option>
                                            <option value="1">是</option>';}
											?>
							  </select>
							</div>
							<div class="form-group">
							  <label>是否开放注册</label>
							  <select name="kf" class="form-control">
							  <?php if($kf == 1)
											{echo '<option value="0">否</option>
                                            <option value="1" selected>是</option>';}
											else 
											{echo '<option value="0" selected>否</option>
                                            <option value="1">是</option>';}
											?>
							  </select>
							</div>
							<div class="form-group">
							  <label>是否开放签到</label>
							  <select name="qd" class="form-control">
							  <?php if($qd == 1)
											{echo '<option value="0">否</option>
                                            <option value="1" selected>是</option>';}
											else 
											{echo '<option value="0" selected>否</option>
                                            <option value="1">是</option>';}
											?>
							  </select>
							</div>
							<div class="form-group">
                                <label for="txtDomain">签到奖励余额</label>
                                <input type="text" name="qd_rmb" class="form-control" value='<?php echo $qd_rmb?>'>
                            
							</div>
							<div class="form-group">
							  <label>前台是否显示</label>
							  <select name="qt" class="form-control">
							  <?php if($qt == 1)
											{echo '<option value="0">否</option>
                                            <option value="1" selected>是</option>';}
											else 
											{echo '<option value="0" selected>否</option>
                                            <option value="1">是</option>';}
											?>
							  

							  </select>
							</div>
							<div class="form-group">
                                <label for="txtDomain">下载地址</label>
                                <input type="text" name="url" class="form-control" value='<?php echo $url?>'>
                            
							</div>
							 <div class="form-group">
                                <label for="txtDomain">状态</label>
                                <select name="zt" class="form-control">
                                            
											<?php if($zt == 1)
											{echo '<option value="0">禁用</option>
                                            <option value="1" selected>正常</option>';}
											else 
											{echo '<option value="0" selected>禁用</option>
                                            <option value="1">正常</option>';}
											?>
                                        </select>
								<span class="help-block">当前状态：<?php if($zt==0){ echo "<font color='red'>禁用中</font>";} else {echo "<font color='red'>正常</font>";} ?></span>									
                            </div>
							
							<div class="form-group">
                                <label for="txtDomain">最新Key</label>
                                <input type="text" name="nkey" class="form-control" value='<?php echo $nkey?>'>
                            </div>
							
							<div class="form-group">
                                <label for="txtDomain">天卡原价</label>
                                <input type="text" name="jg1" class="form-control" value='<?php echo $jg1?>'>
                            </div>
							<div class="form-group">
                                <label for="txtDomain">周卡原价</label>
                                <input type="text" name="jg2" class="form-control" value='<?php echo $jg2?>'>
                            </div>
							<div class="form-group">
                                <label for="txtDomain">月卡原价</label>
                                <input type="text" name="jg3" class="form-control" value='<?php echo $jg3?>'>
                            </div>
							<div class="form-group">
                                <label for="txtDomain">季卡原价</label>
                                <input type="text" name="jg4" class="form-control" value='<?php echo $jg4?>'>
                            </div>
							<div class="form-group">
                                <label for="txtDomain">年卡原价</label>
                                <input type="text" name="jg5" class="form-control" value='<?php echo $jg5?>'>
                            </div>
							<div class="form-group">
                                <label for="txtDomain">永久原价</label>
                                <input type="text" name="jg6" class="form-control" value='<?php echo $jg6?>'>
                            </div>
							
							
							<div class="form-group">
                                <label for="txtDomain">授权商->代理商</label>
                                <input type="text" name="xjjg1" class="form-control" value='<?php echo $xjjg1?>'>
                            </div>
							<div class="form-group">
                                <label for="txtDomain">总销商->授权商</label>
                                <input type="text" name="xjjg2" class="form-control" value='<?php echo $xjjg2?>'>
                            </div>
							<div class="form-group">
                                <label for="txtDomain">总销商->代理商</label>
                                <input type="text" name="xjjg3" class="form-control" value='<?php echo $xjjg3?>'>
                            </div>
							<div class="form-group">
                                <label for="txtDomain">超管->总销商</label>
                                <input type="text" name="xjjg4" class="form-control" value='<?php echo $xjjg4?>'>
                            </div>
							<div class="form-group">
                                <label for="txtDomain">超管->授权商</label>
                                <input type="text" name="xjjg5" class="form-control" value='<?php echo $xjjg5?>'>
                            </div>
							<div class="form-group">
                                <label for="txtDomain">超管->代理商</label>
                                <input type="text" name="xjjg6" class="form-control" value='<?php echo $xjjg6?>'>
                            </div>
							<input type='hidden' name="id" class="user" value='<?php echo $id?>'/>
			<div id="bottom">
			  <button class="btn btn-info" type="submit" value="true" id="submit"/><strong>更新产品</strong></button>
            </div>
                        </form>
                    </section>
                    <!--work progress end-->
                </div>

        </section>
    </section>
    <!--main content end-->

<?php include 'footer.php';?>